{extend name="Base/base"/}

{block name="body"}
    <div class="main-title">
        <h2>
            {present name="data"}{$data.title} 子{/present}
            {:lang('_MENU_MANAGER_')}
        </h2>
    </div>

    <div class="clearfix row with-padding">
        <div class="col-xs-10">
            <a class="btn btn-ajax btn-success btn" href="{:url('',array('parent_id'=>input('get.id',0)))}">{:lang
                ('_MENU_CATEGORY_')}</a>
            <a class="btn btn-ajax btn-success btn"
               href="{:url('',array('action'=>'add','parent_id'=>input('get.id',0)))}">{:lang
                ('_ADD_CATEGORY_')}</a>
            <button class="btn ajax-post confirm" url="{:url('del')}" target-form="ids">{:lang('_DELETE_WITH_SPACE_')}</button>
        </div>
        <!-- 选择框 -->
        <div class="col-xs-2">
            <form id="selectForm" method="get" action="/uctoo/admin.php?s=/shop/product_cats.html" class="">
                <div class="oneselect">
                    <div class="">分类查看</div>
                    <div class="select_box">
                        <select name="parent_id" data-role="select_text" class="form-control">
                            <option value="0">顶级分类</option><option value="1" selected="">aaa&nbsp;</option>
                        </select>
                    </div>
                </div>
            </form>
        </div>

    </div>

    <div class="with-padding">

        <form class="ids">
            <table class="table table-bordered table-striped table-hover">
                <thead>
                <tr>
                    <th class="row-selected">
                        <input class="checkbox check-all" type="checkbox">
                    </th>
                    <th>{:lang('_TITLE_')}</th>
                    <th>{:lang('_TITLE_EN_')}</th>
                    <th>{:lang('_IMAGE_')}</th>
                    <th>{:lang('_SORT_')}</th>
                    <th>{:lang('_CREATE_TIME_')}</th>
                    <th>{:lang('_STATUS_')}</th>
                    <th>{:lang('_OPERATE_')}</th>
                </tr>
                </thead>
                <tbody>
                {notempty name="list"}
                    {volist name="list" id="menu"}
                        <tr>
                            <td><input class="ids row-selected" type="checkbox" name="id" value="{$menu.id}"></td>
                            <td>{$menu.title}</td>
                            <td>{$menu.title_en}</td>
                            <td>{$menu.image}</td>
                            <td>{$menu.sort}</td>
                            <td>{$menu.create_time|date='Y-m-d H:i',###}</td>
                            <td>{$menu.status}</td>
                            <td>
                                <a title="{:lang('_EDIT_')}"
                                   href="{:url('',array('action'=>'add','id'=>$menu['id']))}">{:lang
                                    ('_EDIT_')}</a>
                                <a class="confirm ajax-get" title="{:lang('_DELETE_')}"  href="{:url('del?id='.$menu['id'])}">{:lang('_DELETE_')}</a>
                            </td>
                        </tr>
                    {/volist}
                    {else/}
                    <td colspan="10" class="text-center">{:lang('_ADMIN_USER_EMPTY_')}</td>
                {/notempty}
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <div class="page">
            {$page}
        </div>
    </div>
{/block}

{block name="script"}
    <script type="text/javascript">
        $(function () {
            //搜索功能
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function (e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮

            //点击排序
            $('.list_sort').click(function () {
                var url = $(this).attr('url');
                var ids = $('.ids:checked');
                var param = '';
                if (ids.length > 0) {
                    var str = new Array();
                    ids.each(function () {
                        str.push($(this).val());
                    });
                    param = str.join(',');
                }

                if (url != undefined && url != '') {
                    window.location.href = url + '/ids/' + param;
                }
            });
        });
    </script>
{/block}